FROM ubuntu:latest
LABEL authors="JHC"


ENV WORKPATH=/home/jiaohaicheng
ENV PROJECTNAME=celery_test
ENV PROJECTPATH="${WORKPATH}/${PROJECTNAME}"
ENV PYTHONVENVPATH="${WORKPATH}/venv"

WORKDIR ${WORKPATH}

USER root

RUN apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get -y install \
        sudo \
    && apt-get clean


RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive sudo apt-get -y install \
    software-properties-common \
    python-is-python3 \
    python3-pip \
    python3-venv && \
    apt-get clean

RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive sudo apt-get -y install \
    redis-server && \
    apt-get clean

RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get -y install \
    mysql-server && \
    apt-get clean &&  \
    service redis-server start

RUN sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

RUN echo "set fileencodings=utf-8,gb2312,gbk,gb18030\nset termencoding=utf-8\nset fileformats=unix\nset encoding=prc" >> ~/.vimrc

RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive sudo apt-get -y install  \
    language-pack-zh-hans \
    language-pack-zh-hans-base\
    nginx


COPY . .
RUN python3 -m venv "${PYTHONVENVPATH}" && "${PYTHONVENVPATH}/bin/pip" install -r "${PROJECTPATH}/requirements.txt" -i https://mirrors.aliyun.com/pypi/simple/

ENTRYPOINT ["sh","-c" ,"${PROJECTPATH}/start.sh"]
